from typing import List


class Solution:
    def mergeTriplets(self, triplets: List[List[int]], target: List[int]) -> bool:
        size = len(triplets)
        find0, find1, find2 = False, False, False
        for i in range(size):
            triplet = triplets[i]
            if triplet[0] == target[0] and triplet[1] <= target[1] and triplet[2] <= target[2]:
                find0 = True
            if triplet[1] == target[1] and triplet[0] <= target[0] and triplet[2] <= target[2]:
                find1 = True
            if triplet[2] == target[2] and triplet[0] <= target[0] and triplet[1] <= target[1]:
                find2 = True
            if find0 and find1 and find2:
                return True
        return False


if __name__ == "__main__":
    print(Solution().mergeTriplets(triplets=[[2, 5, 3], [1, 8, 4], [1, 7, 5]], target=[2, 7, 5]))  # True
    print(Solution().mergeTriplets(triplets=[[1, 3, 4], [2, 5, 8]], target=[2, 5, 8]))  # True
    print(Solution().mergeTriplets(triplets=[[2, 5, 3], [2, 3, 4], [1, 2, 5], [5, 2, 3]], target=[5, 5, 5]))  # True
    print(Solution().mergeTriplets(triplets=[[3, 4, 5], [4, 5, 6]], target=[3, 2, 5]))  # False
